#include <iostream>       
#include <future>         
#include <chrono>

int getData(int x) {
    std::cout << "async thread run start!"<<std::endl;
    std::this_thread::sleep_for(std::chrono::milliseconds(6000));
    std::cout << "async thread run end!" << std::endl;

    return x;
}

int main()
{
    //在std::async中，std::future的临时变量会在没有被移动或者引用情况下一直阻塞到异步计算完成
    auto asc=std::async(std::launch::async, getData, 100);

    std::cout << "go to ..."<<std::endl;

    return 0;
}
 